package com.itboye.textileexpes.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.CreateOrderBeans;
import com.itboye.textileexpes.beans.MyOrderBeans;
import com.itboye.textileexpes.interfaces.IMyOrder;
import com.itboye.textileexpes.repository.MyOrderRepository;
import com.itboye.textileexpres.base.BasePresenter;
import com.itboye.textileexpres.base.ResultEntity;

/**
 * 订单分页查询
 */
public class MyOrderPresenter extends BasePresenter implements
		IMyOrder<MyOrderBeans> {
	/**
	 * 订单分页查询
	 */
	public static final String Fenye_success = MainPresenter.class.getName()
			+ "_Fenye_success";
	public static final String Fenye_fail = MainPresenter.class.getName()
			+ "_Fenye_fail";

	/**
	 * 订单xiangqing
	 */
	public static final String Xiang_success = MainPresenter.class.getName()
			+ "_Xiang_success";
	public static final String Xiang_fail = MainPresenter.class.getName()
			+ "_Xiang_fail";

	/**
	 * 删除订单
	 */
	public static final String Delete_success = MainPresenter.class.getName()
			+ "_Delete_success";
	public static final String Delete_fail = MainPresenter.class.getName()
			+ "_Delete_fail";

	/**
	 * 搜索订单
	 */
	public static final String Search_success = MainPresenter.class.getName()
			+ "_Search_success";
	public static final String Search_fail = MainPresenter.class.getName()
			+ "_Search_fail";

	/**
	 * 确定收货
	 */
	public static final String Btn_success = MainPresenter.class.getName()
			+ "_Btn_success";
	public static final String Btn_fail = MainPresenter.class.getName()
			+ "_Btn_fail";

	/**
	 * 定单取消
	 */
	public static final String Cance_success = MainPresenter.class.getName()
			+ "_Cance_success";
	public static final String Cance_fail = MainPresenter.class.getName()
			+ "_Cance_fail";

	public static final String Create_success = MainPresenter.class.getName()
			+ "_Create_success";
	public static final String Create_fail = MainPresenter.class.getName()
			+ "_Create_fail";
	public static final String Create_Now_success = MainPresenter.class
			.getName() + "_Create_Now_success";
	public static final String Create_Now_fail = MainPresenter.class.getName()
			+ "_Create_Now_fail";

	public MyOrderPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(MyOrderBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(MyOrderBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(MyOrderBeans model) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Search_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Search_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.update(model);
	}

	@Override
	public void getInfo(MyOrderBeans model) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Fenye_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Fenye_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.getInfo(model);
	}

	@Override
	public List<MyOrderBeans> query(MyOrderBeans model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getorder(String uid, String order_code) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Xiang_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Xiang_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.getorder(uid, order_code);
	}

	@Override
	public void getDelete(String uid, String order_code) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Delete_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Delete_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.getDelete(uid, order_code);
	}

	@Override
	public void getBtnSendOrder(String uid, String order_code) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Btn_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Btn_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.getBtnSendOrder(uid, order_code);
	}

	@Override
	public void getOrdercancel(String uid, String order_code) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Cance_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Cance_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.getOrdercancel(uid, order_code);
	}

	@Override
	public void createOrder(CreateOrderBeans beans) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Create_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Create_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.createOrder(beans);
	}

	@Override
	public void createOrderBuyNow(CreateOrderBeans beans) {
		// TODO Auto-generated method stub
		IMyOrder<MyOrderBeans> goods = new MyOrderRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Create_Now_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Create_Now_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		goods.createOrderBuyNow(beans);
	}

}
